package cn.kooki.app.duobao.ui.view;

import android.content.Context;
import android.view.LayoutInflater;
import android.widget.FrameLayout;
import android.widget.TextView;

import cn.kooki.app.duobao.R;

/**
 * Created by xiong on 2015/12/17.
 */
public class LoadmoreFooter extends FrameLayout {


    public final static int isLoadingData = 1;

    public final static int NORMAL = 0;

    public final static int LOADING_COMPELETE = 2;

    public final static int ISEND = 3;

    public final static int ISNOTENABLE = 4;

    public int type=NORMAL;

    private LoadingProgressView lo;
    private TextView loadingtext;


    public LoadmoreFooter(Context context) {
        super(context);
        initView();
    }

    private void initView() {
        LayoutInflater.from(getContext()).inflate(R.layout.layout_loading_more, this, true);
        lo = (LoadingProgressView) findViewById(R.id.loading_more_progress);
        loadingtext = (TextView) findViewById(R.id.loading_text);
        lo.setVisibility(GONE);
        lo.startAniation();
        loadingtext.setVisibility(INVISIBLE);
    }

    public void setType(int type) {
        this.type = type;
        changeState();
    }

    private void changeState() {
        switch (type){
            case NORMAL:
                lo.setVisibility(GONE);
                loadingtext.setVisibility(INVISIBLE);
                loadingtext.setText(R.string.loading_more);
                break;
            case isLoadingData:
                lo.setVisibility(VISIBLE);
                loadingtext.setVisibility(VISIBLE);
                loadingtext.setText(R.string.loading_more);
                break;
            case LOADING_COMPELETE:
                lo.setVisibility(GONE);
                loadingtext.setVisibility(VISIBLE);
                loadingtext.setText(R.string.loading_complete);
                break;
            case ISEND:
                lo.setVisibility(GONE);
                setVisibility(VISIBLE);
                loadingtext.setVisibility(VISIBLE);
                loadingtext.setText(R.string.end);
                break;
            case ISNOTENABLE:
                lo.setVisibility(GONE);
                loadingtext.setVisibility(GONE);
                break;
        }
    }
}
